package com.xusiyan08.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.PostConstruct;

@RestController
public class PortController {

    @Value("${server.port}")
    private String serverPort;

    @PostConstruct
    public void logPort() {
        System.out.println("服务启动成功，当前端口: " + serverPort);
    }

    @GetMapping("/port")
    public String getPort() {
        System.out.println("请求到达，当前服务端口: " + serverPort);
        return "当前服务端口: " + serverPort;
    }
}
